<?php
/**
 * get upload status action
 *
 * @package    upload
 * @author     ben
 */
class saveAction extends WacCommonActions {
    public function execute($request) {
//        $this->form = new ContactForm();
//
//        if ($request->isMethod('post')) {
//            $this->form->bind($request->getParameter('contact'));
//            if ($this->form->isValid()) {
//                $this->redirect('upload/index?'.http_build_query($this->form->getValues()));
//            }
//        }
//
//        return sfView::NONE;

//        if(!$request->hasParameter('APC_UPLOAD_PROGRESS')) $this->forward404();
        sfConfig::set('sf_web_debug', false);

//        $fileObj = $this->getRequest()->getFiles('test_file');


        var_dump($_FILES["up_files"]);
//        $fileObj->save(sfConfig::get('sf_upload_dir').'/'."test.txt");

        foreach ($_FILES["up_files"]["error"] as $key => $error) {
            if ($error == UPLOAD_ERR_OK) {
                $tmp_name = $_FILES["up_files"]["tmp_name"][$key];
                $name = $_FILES["up_files"]["name"][$key];
                move_uploaded_file($tmp_name, sfConfig::get('sf_upload_dir')."/files/{$name}");
            }
        }
        
        $resultArr = array();
        return OutputHelper::getInstance()->outputJsonOrTextFormat($resultArr, $this);
    }
}